package com.zycfc.zsf.boot.exception.type;

import com.zycfc.zsf.boot.exception.*;

public enum ExceptionCode implements IExceptionCode
{
    FAIL("9999999", "\u64cd\u4f5c\u5931\u8d25"), 
    NOT_MODIFIED("1010304", "\u672a\u4fee\u6539"), 
    BAD_REQUEST("1010400", "\u8bf7\u6c42\u53c2\u6570\u6709\u8bef,\u6bd4\u5982\u8bf7\u6c42\u5934\u4e0d\u5bf9\u3001\u53c2\u6570\u9a8c\u8bc1\u5931\u8d25\u7b49"), 
    UNAUTHORIZED("1020401", "\u672a\u767b\u5f55\u6216\u767b\u5f55\u5df2\u8fc7\u671f"), 
    FORBIDDEN("1020403", "\u6ca1\u6709\u6743\u9650"), 
    NOT_FOUND("1010404", "\u672a\u627e\u5230\u8bb0\u5f55"), 
    INTERNAL_SERVER_ERROR("1010500", "\u4e1a\u52a1\u5904\u7406\u9519\u8bef"), 
    SERVICE_UNAVAILABLE("1010503", "\u670d\u52a1\u4e0d\u53ef\u7528"), 
    SERVICE_HTTP_STATUS_ERROR("1010504", "\u7531\u975e\u6cd5\u53c2\u6570\u6216\u8005\u4e00\u4e9b\u975e\u7cfb\u7edf\u5f02\u5e38\u5f15\u8d77\u5f02\u5e38"), 
    IDEMPOTENT_EXE_ING("1020001", "\u6267\u884c\u4e2d"), 
    DATA_VALID("1030001", "\u6570\u636e\u6821\u9a8c\u5f02\u5e38"), 
    DB_EXECUTE_EXCEPTION("1010505", "\u6570\u636e\u5e93\u6267\u884c\u5f02\u5e38");
    
    private final String value;
    private final String message;
    
    private ExceptionCode(final String value, final String message) {
        this.value = value;
        this.message = message;
    }
    
    public static ExceptionCode getValue(final int value) {
        return getValue(String.valueOf(value));
    }
    
    public static ExceptionCode getValue(final String value) {
        if (null == value) {
            return null;
        }
        for (final ExceptionCode item : values()) {
            if (value.equals(item.value)) {
                return item;
            }
        }
        return null;
    }
    
    public String getValue() {
        return this.value;
    }
    
    public String getMessage() {
        return this.message;
    }
}
